<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-31 17:46:49
 * @LastEditTime: 2019-11-28 15:58:02
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../../css/local.css" />
    <link rel="stylesheet" type="text/css" href="../../font/iconfont.css" />
    <link rel="stylesheet" href="../../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/layer/layer.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <script type="text/javascript" src="../../script/fastclick.js"></script>
    <script src="../../script/elementui/lib/index.js?t=1"></script>
    <script src="../../script/elementui/vue-element-bigdata-table.min.js?t=4"></script>
    <script type="text/javascript" src="../../script/base.js"></script>
    <script type="text/javascript" src="../../script/JSLINQ.js"></script>
    <script type="text/javascript" src="../../script/ajaxFileUpload.js"></script>
    <style type="text/css">
        body {
            zoom: 0.9;
        }

        .innerBox {
            flex: 1;
            overflow: auto;
        }

        .mainForm {
            /* height: 60%; */
            width: 99%;
            /* overflow-y: auto; */
            display: flex;
            flex-wrap: wrap;
        }

        .van-field {
            width: 50%;
        }

        .van-field__label {
            width: auto;
        }

        .subFrame {
            /* width: 100%; */
        }

        .title {
            width: 25%;
            background-color: #83bff6;
            text-align: center;
            margin: 2px auto 2px 0;
            padding: 4px 1px;
            color: #fff;
            font-size: 17px;
        }

        .van-icon-delete {
            color: red;
        }

        .van-tabs {
            width: 100%;
            height: auto;
        }

        .van-tabs__wrap {
            width: 70vw;
        }

        .van-tabs__nav--card {
            border: 1px solid #83bff6;
        }

        .van-tab--card.van-tab--active {
            background-color: #83bff6;
        }

        .van-tab--card {
            color: #83bff6;
            border-right: #83bff6;
        }

        .van-tab {
            padding: 0;
            margin: 0;
        }

        .van-tabs__content {
            width: 100%;
        }

        .van-tabs__nav {
            width: 25%;
        }

        .part {
            width: 100%;
            margin-top: 0px;
            padding: 0px 5px 3px 5px;
            box-sizing: border-box;
        }

        .part .pf {
            border-radius: 6px;
            box-shadow: 0px 1px 5px rgb(200, 198, 198);
            background-color: #fff;
            overflow: hidden;
            position: relative;
            margin-top: 10px;
        }

        .van-badge {
            margin: 10px 10px;
            background-color: #1989fa;
            color: #fff;
            display: block;
            width: 22px;
            padding: 3px;
            float: left;
            vertical-align: middle;
        }

        .van-cell,
        .van-field {
            width: 100%;
            padding: 5px 16px !important;
        }

        .van-cell {
            padding: 10px 8px 10px 12px;
        }

        .form .van-cell__title {
            max-width: 77px;
            color: #969799;
        }

        .form .van-cell__value {
            text-align: left;
        }

        .van-field__label {
            width: 105px;
            color: #969799;
        }

        .van-cell::after {
            position: absolute;
            box-sizing: border-box;
            content: ' ';
            pointer-events: none;
            right: 8px;
            bottom: 0;
            left: 12px;
            border-bottom: 1px solid #ebedf0;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
        }

        .part1 {
            padding: 15px 15px 0 15px;
        }

        .part1 .pf {
            border-radius: 6px;
            box-shadow: 0px 1px 5px rgb(200, 198, 198);
            background-color: #fff;
            overflow: hidden;
        }

        .textarea {
            display: block;
        }

        .label {
            padding: 10px 16px;
        }

        .ap-f {
            border-bottom: 1px solid #f7f7f7;
        }

        .mark {
            padding: 17px 15px;
        }

        .mark1 {
            padding: 17px 5px 17px 15px;
            position: relative;
        }

        .f-sub {
            color: #969799;
            font-size: 13px;
            margin-top: 4px;
        }

        .line {
            position: relative;
            width: 30px;
        }

        .line1 {
            width: 60px;
        }

        .line-sq {
            display: inline-block;
            width: 11px;
            height: 11px;
            border-radius: 6px;
            background: #d6d6d6;
            position: absolute;
            left: 0;
            top: 12px;
        }

        .line-li {
            display: inline-block;
            width: 1px;
            background: #d6d6d6;
            position: absolute;
            left: 5px;
            top: -17px;
            bottom: -17px;
        }

        .line-li1 {
            display: inline-block;
            background: #d6d6d6;
            position: absolute;
            top: 52px;
            left: 35px;
            width: 3px;
            bottom: 10px;
        }

        .pd {
            padding: 16px 0;
        }

        .ap-r {
            text-align: right;
            padding-right: 10px;
            /* margin: -8px 0; */
            padding-top: 10px;
        }

        .ap-d {
            text-align: right;
            padding-right: 10px;
            color: #ccccce;
            font-size: 13px;
            float: right;
            padding-top: 3px;
        }

        .img {
            width: 34px;
            height: 34px;
            line-height: 34px;
            text-align: center;
            font-size: 12px;
            color: #fff;
            background-color: #3396fb;
            border-radius: 6px;
            margin: 0 auto;
            position: relative;
            user-select: none;
        }

        .img1 {
            width: 44px;
            height: 44px;
            line-height: 44px;
            text-align: center;
            font-size: 13px;
            color: #fff;
            background-color: #3396fb;
            border-radius: 6px;
            position: relative;
            user-select: none;
        }

        .dis-ib {
            display: inline-block;
            vertical-align: middle;
            text-align: center;
            min-width: 40px;
        }

        .dis2-ib {
            display: inline-block;
            vertical-align: middle;
            padding-bottom: 3px;
            text-align: center;
        }

        .dis3-ib {
            display: inline-block;
            margin: 0 6px;
            color: #969799;
            vertical-align: top;
            padding-top: 7px;
            text-align: center;
        }

        .ap-n {
            padding-top: 2px;
            font-size: 13px;
            color: #969799;
            text-align: center;
        }

        .bottom {
            padding: 8px 15px;
        }

        .part-white {
            padding: 15px;
            background-color: #fff;
            position: relative;
        }

        .title {
            line-height: 40px;
            font-size: 18px;
        }

        .title-sub {
            color: #aaacac;
            font-size: 13px;
        }

        .title-read {
            color: #3396fb;
            font-size: 13px;

        }

        .title-unread {
            color: #788a8a;
            font-size: 13px;
        }

        .ap-res {
            color: #a3a3a3;
            font-size: 15px;
            padding-top: 6px;
        }

        .ap-res1 {
            color: #c31616;
            font-size: 15px;
            padding-top: 6px;
        }

        .ap-img {
            position: absolute;
            right: 20px;
            bottom: -38px;
            width: 88px;
            opacity: 0.4;
        }

        .form-row {
            padding: 4px 16px;
        }

        .form-label {
            color: #808991;
            font-size: 13px;
            user-select: none;
        }

        .form-content {
            padding-top: 5px;
        }

        .npd {
            padding-top: 0;
            overflow-x: auto;
        }

        .pl {
            color: #969799;
            font-size: 16px;
            margin: 6px 2px 18px 0;
            min-height: 25px;
            border-bottom: 1px solid #ebedf0;
        }

        .sf {
            width: 16px;
            background: #fff;
            padding: 2px;
            border-radius: 8px;
            position: absolute;
            right: -5px;
            bottom: -2px;
        }

        .select {
            color: #3396fb;
            float: right;
            font-size: 13px;
            padding-top: 3px;
            vertical-align: middle;
        }

        .select a {
            vertical-align: middle;
        }

        .select img {
            width: 16px;
            vertical-align: middle;
        }

        .hq {
            padding: 10px 10px 0 0;
        }

        .wh {

            white-space: nowrap;
            overflow-x: auto;
            padding-right: 10px;
        }

        .plpd {
            padding-bottom: 5px;
        }

        .pictitle {
            line-height: 24px;
            color: #646566;
            user-select: none;
        }

        .piccontent {
            padding-top: 10px;
            overflow: hidden;
        }

        .van-uploader__preview {
            margin-right: 15px;
        }

        .no {
            text-align: center;
            color: #808991;
            font-size: 14px;
        }

        .li1 {
            top: 15px;
        }

        .li2 {
            bottom: 24px;
        }

        .da-c {
            color: #c31616;
        }

        .danger .van-field__control {
            color: #c31616;
        }

        .danger .van-field__label {
            color: #808991;
        }

        .ac-1 {
            color: #03b553;
        }

        .ac-2 {
            color: #c31616;
        }

        .checkbox {
            padding: 25px 5px 10px 10px;
        }

        .jl-remark {
            padding: 5px 0;
            color: #3396fb;
        }

        .memo-l {
            border-bottom: 1px solid rgb(235, 237, 240);
            padding: 4px 0;
        }

        .memo-l:last-child {
            border-bottom: 0;
        }

        .approvePop {
            box-sizing: border-box;
            padding: 20px 30px;
        }

        .approvePop .approveBtns {
            position: absolute;
            bottom: 0;
            width: 100%;
            box-sizing: border-box;
            display: flex;
        }

        .approvePop .approveBtns .van-button {
            width: 60%;
            margin: auto;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box" id="box">
            <van-nav-bar id="van-nav-bar" :title="titleName" left-arrow @click-left="onClickLeft">
                <div slot="right">
                    <span slot="right" @click="openScan" v-if="!isPDA">
                        <img src="../../image/scan.png" />
                    </span>
                    <span slot="right" @click="openPrint" v-if="isPDA && printConfig">
                        <img src="../../image/print.png" />
                    </span>
                </div>
            </van-nav-bar>

            <div class="innerBox">
                <div class="mainForm">
                    <van-field v-model="formData.BillDate" label="单据日期" placeholder="请输入单据日期" readonly>
                    </van-field>
                    <van-field v-model="formData.BillNO" label="单据编号" placeholder="请输入单据编号" readonly>
                    </van-field>
                    <van-field v-model="formData.MJLXName" readonly @click="openBaseScreen('模具类型')" label="模具类型"
                        placeholder="请输入模具类型" required class='label1'>
                    </van-field>
                    <van-field v-model="formData.MoludTypeName" v-show="formData.MJLXName != '请购'" label="模具分类"
                        placeholder="请输入模具分类" readonly is-link @click="openBaseScreen('模具分类')">
                    </van-field>
                    <van-field v-model="formData.ReasonApplication" label="申请事由" placeholder="请输入申请事由">
                    </van-field>
                    <van-field v-model="formData.TotalPrice" label="总价" placeholder="请输入总价" readonly>
                    </van-field>
                    <van-field v-model="formData.EmplName" label="申请人" placeholder="请输入申请人" readonly is-link
                        @click="openBaseScreen('申请人')">
                    </van-field>
                    <van-field v-model="formData.ClassName" label="申请人部门" placeholder="请输入申请人部门" readonly is-link
                        @click="getClass()"></van-field>
                    <van-field v-model="formData.ApplicationDate" label="申请日期" placeholder="请输入申请日期" readonly is-link
                        @click="ApplicationDateshow=true">
                    </van-field>
                    <van-field v-model="formData.ExpectDate" label="期望交付日期" placeholder="请输入期望交付日期" readonly is-link
                        @click="currentExpectDateShow = true">
                    </van-field>

                    <van-field name="uploader" label="附件" readonly>
                        <template #input>
                            <div class="van-uploader">
                                <!-- 整行图片 -->
                                <div class="van-uploader__wrapper">
                                    <!-- 单个照片 -->
                                    <div class="van-uploader__preview" v-for="(item, index) in formData.FilePath">
                                        <van-image @click="previewImg" width="80" height="80"
                                            :src="serverIP + item.url">
                                        </van-image>
                                        <div @click="deleteImg(index)" class="van-uploader__preview-delete"
                                            style="width: 30px; height: 30px">
                                            <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                                                style="font-size: 30px"></i>
                                        </div>
                                    </div>

                                    <!-- 上传图片的按钮 -->
                                    <div v-show="formData.FilePath.length < 9" class="van-uploader__upload"
                                        @change="uploadNewFile(1)">
                                        <i
                                            class="van-badge__wrapper van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                        <input type="file" name="newFile1" id="newFile1" accept="image/*"
                                            class="van-uploader__input">
                                    </div>
                                </div>
                            </div>
                        </template>
                    </van-field>

                    <van-field v-model="formData.FRemarks" label="备注" placeholder="请输入备注">
                    </van-field>
                    <van-field v-model="formData.ReviewStatus" label="审批状态" placeholder="请输入审批状态"></van-field>
                </div>

                <div class="subFrame">
                    <van-tabs v-model:active="currentActive" type="card">
                        <van-tab title="请购报废明细" name="1">
                            <div style="width:100%;height:35px;">
                                <van-button icon="add" type="info" size="small" style="margin-right:5px;float:right"
                                    @click="addNewSubTable">添加子表信息
                                </van-button>
                            </div>
                            <div>
                                <div class="part">
                                    <van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了">
                                        <div class="pf" v-for="(item, index) in tableData">
                                            <div class="pftitle">
                                                <div class="van-badge">{{ index + 1 }}</div>
                                                <van-icon name="delete-o" style="float:right;padding:10px 15px"
                                                    @click="deleteTableData(index)" color="#f00"></van-icon>
                                            </div>
                                            <div>
                                                <van-field v-show="formData.MJLXName != '请购'" v-model="item.MoludCode"
                                                    label="模具编号" placeholder="请输入模具编号" readonly is-link
                                                    @click="openBaseScreen('模具编号', index)"></van-field>

                                                <van-field v-show="formData.MJLXName != '请购'" v-model="item.models"
                                                    label="模具图号" placeholder="请输入模具图号" readonly>
                                                </van-field>

                                                <van-field v-show="formData.MJLXName == '请购'" v-model="item.ProductCode"
                                                    label="品号" placeholder="请输入品号" is-link readonly
                                                    @click="openBaseScreen('品号', index)">
                                                </van-field>
                                                <van-field v-show="formData.MJLXName == '请购'" v-model="item.ProductName"
                                                    label="品名" placeholder="请输入品名称" readonly>
                                                </van-field>
                                                <van-field v-show="formData.MJLXName == '请购'" v-model="item.ProductSpec"
                                                    label="规格" placeholder="请输入规格" readonly>
                                                </van-field>
                                                <van-field v-show="formData.MJLXName == '请购'" v-model="item.CPTH"
                                                    label="图号" placeholder="请输入图号" readonly>
                                                </van-field>
                                                <van-field v-show="formData.MJLXName != '请购'" v-model="item.MoludName"
                                                    label="模具名称" placeholder="请输入模具名称" readonly>
                                                </van-field>

                                                <van-field v-model="item.GRDate" v-show="formData.MJLXName != '请购'"
                                                    readonly is-link @click="chnageGRDateShow(index)" label="购入时间"
                                                    placeholder="请输入购入时间">
                                                </van-field>
                                                <van-field v-model="item.FQty" readonly
                                                    v-show="formData.MJLXName != '请购'" label="产量" placeholder="请输入产量">
                                                </van-field>
                                                <van-field v-model="item.Qty" v-if="formData.MJLXName == '请购'"
                                                    label="数量" placeholder="请输入数量"
                                                    @input="handlerTotalPrice(item.Qty,index)">
                                                </van-field>
                                                <van-field v-else v-model="item.Qty" readonly label="数量"
                                                    placeholder="请输入数量" @input="handlerTotalPrice(item.Qty,index)">
                                                </van-field>
                                                <van-field v-show="formData.MJLXName == '请购'" v-model="item.UnitName"
                                                    label="单位" placeholder="请输入单位">
                                                </van-field>
                                                <van-field v-model="item.Price" label="价格" placeholder="请输入价格"
                                                    @input="handlerTotalPrice(item.Price,index)">
                                                </van-field>
                                                <van-field v-show="formData.MJLXName =='请购'" v-model="item.Money"
                                                    label="金额" placeholder="请输入金额">
                                                </van-field>
                                                <van-field v-model="item.EquipmentTypeName" readonly label="吨位"
                                                    placeholder="请输入吨位" is-link @click="openBaseScreen('吨位', index)">
                                                </van-field>
                                                <van-field v-show="formData.MJLXName != '请购'"
                                                    v-model="item.FStorageCode" label="库位" readonly placeholder="请输入库位"
                                                    @click="openBaseScreen('库位', index)">
                                                </van-field>
                                            </div>
                                        </div>
                                    </van-list>
                                </div>
                            </div>
                        </van-tab>
                    </van-tabs>

                    <div class="part1" v-for="approvalRow in approvalList">
                        <div class="pf">
                            <div class="label">流程</div>
                            <div class="pd">
                                <div>
                                    <div class="flex-box f-r">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1"><span>{{formData.UserName}}</span><img
                                                                class="sf" src="../../image/success.png" /></div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"></div>
                                            </div>

                                        </div>
                                        <div class="flex-main npd">
                                            <div>
                                                <div>
                                                    <span>发起审批</span>
                                                    <span
                                                        class="ap-d">{{formData.BillDate.split('.')[0].replace(/T/g,'')}}</span>
                                                </div>
                                                <div class="f-sub">{{formData.UserName}}</div>
                                            </div>
                                            <div class="pl"></div>
                                        </div>
                                    </div>
                                </div>
                                <div v-for="(row,index) in approvalRow.approvalNodeList">
                                    <div class="flex-box f-r">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1">
                                                            <span
                                                                v-if="row.node.length == 1 && row.node[0].CurrentApprovalIDs.length == 1 && row.type == 0">{{row.node[0].CurrentApprovalIDs[0]}}</span>
                                                            <van-icon v-else-if="row.type == 1" name="volume-o"
                                                                size="28px" style="padding-top: 7px;">
                                                            </van-icon>
                                                            <van-icon v-else name="friends-o" size="28px"
                                                                style="padding-top: 7px;"></van-icon>
                                                            <img class="sf"
                                                                v-if="approvalRow.level == row.index - 2 && row.type == 1 && row.node[0].Approve != 0"
                                                                src="../../image/success.png" />
                                                            <img class="sf" v-if="approvalRow.level >= row.index - 1"
                                                                :src="getApprovalTagImg(row)" />
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"
                                                    v-if="index != approvalRow.approvalNodeList.length - 1"></div>
                                            </div>

                                        </div>
                                        <div class="flex-main npd">
                                            <div>
                                                <div class="hq" v-if="row.showMore">
                                                    <!-- 或签 -->
                                                    <div class="wh"
                                                        v-if="row.node.length == 1 && row.node[0].CurrentApprovalIDs.length > 1">
                                                        <div class="dis2-ib"
                                                            v-for="(item,itemIndex) in row.node[0].CurrentApprovalIDs">
                                                            <div class="dis-ib">
                                                                <div class="img">
                                                                    <span>{{cutStr(item)}}</span>
                                                                    <img class="sf"
                                                                        v-if="item == row.node[0].Approver && approvalRow.level >= row.index - 1 && row.node[0].Approve != 0"
                                                                        :src="row.node[0].Approve == 1?'../../image/success.png':'../../image/fail.png'" />
                                                                </div>
                                                                <div class="ap-n">{{item}}</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node[0].CurrentApprovalIDs.length - 1 && row.type == 0">
                                                                /</div>
                                                            <div class="dis3-ib" v-if="row.type == 1"> </div>
                                                        </div>

                                                    </div>
                                                    <!-- 会签 -->
                                                    <div class="wh" v-if="row.node.length > 1 && checkIsSingle(row)">
                                                        <div class="dis2-ib" v-for="(item,itemIndex) in row.node">
                                                            <div class="dis-ib">
                                                                <div class="img">
                                                                    <span>{{cutStr(item.CurrentApprovalIDs[0])}}</span>
                                                                    <img class="sf"
                                                                        v-if="item.Approver && item.Approver == item.CurrentApprovalIDs[0] && approvalRow.level >= row.index - 1 && item.Approve != 0"
                                                                        :src="item.Approve == 1?'../../image/success.png':'../../image/fail.png'" />
                                                                </div>
                                                                <div class="ap-n">{{item.CurrentApprovalIDs[0]}}</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node.length - 1 && row.type == 0">
                                                                +</div>
                                                            <div class="dis3-ib" v-if="row.type == 1"> </div>
                                                        </div>
                                                    </div>
                                                    <!-- 多人审核 -->
                                                    <div class="wh" v-if="row.node.length > 1 && !checkIsSingle(row)">
                                                        <div class="dis2-ib" v-for="(item,itemIndex) in row.node">
                                                            <div class="dis2-ib"
                                                                v-for="(detail,detailIndex) in item.CurrentApprovalIDs">
                                                                <div class="dis-ib">
                                                                    <div class="img">
                                                                        <span>{{cutStr(detail)}}</span>
                                                                    </div>
                                                                    <div class="ap-n">{{detail}}
                                                                    </div>
                                                                </div>
                                                                <div class="dis3-ib"
                                                                    v-if="itemIndex != row.node.length - 1">/</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node.length - 1">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="pl">
                                                    <div class="plpd" v-for="item in row.node">
                                                        <div>
                                                            <span v-if="item.ApprovalContent"
                                                                :class="'ac-' + item.Approve">{{item.Approver}}:</span>
                                                            <span v-if="item.ApprovalContent"
                                                                :class="'ac-' + item.Approve">"{{item.ApprovalContent}}"</span>
                                                            <div class="ap-d" v-if='item.ApprovalContent'>
                                                                  {{item.ApproveTime}}
                                                            </div>
                                                        </div>

                                                        <div class="piccontent" v-if="item.Imgs">
                                                            <div class="van-uploader">
                                                                <div class="van-uploader__wrapper">
                                                                    <div class="van-uploader__preview"
                                                                        v-for="(imgItem,imgItemIndex) in (item.Imgs?item.Imgs.split(','):[])">
                                                                        <div class="van-image van-uploader__preview-image"
                                                                            style="overflow: hidden; border-radius: 4px;width:60px;height:60px;"
                                                                            @click="previewItemImage(item.Imgs,imgItemIndex,3)">

                                                                            <img :src="serverIP + imgItem"
                                                                                class="van-image__img"
                                                                                style="object-fit: cover;" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="flex-box f-r" v-if="index == approvalRow.approvalNodeList.length - 1">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1">
                                                            <span>备注</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"
                                                    v-if="index != approvalRow.approvalNodeList.length - 1"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bottomSubmit"
                    style="position: fixed;bottom: 0px;z-index: 1;width: 100%;padding: 5px 10px;right:0px">
                    <div style="float:right;width:20%;" v-if="whetherShowBtn">
                        <van-button v-if="!btnShow" round block type="info" native-type="submit" @click="saveRow">提交
                        </van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="approveFalg">
                        <van-button round block type="info" native-type="submit" @click="submit(0)">重新发起审批</van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(2)">拒绝</van-button>
                    </div>
                    <div style="float:right;width:30%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(1)">输入审核意见/确认同意
                        </van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">>
                        <van-button round block type="info" native-type="submit" @click="submit(3)">退回</van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="dialogVisible = true">转交
                        </van-button>
                    </div>
                </div>
            </div>
            <el-dialog title="转交" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
                <!-- <span>这是一段信息</span> -->
                <el-select v-model="TransmittedUserID" filterable placeholder="请选择">
                    <el-option v-for="item in options" :key="item.userid_num" :label="item.user_name"
                        :value="item.userid_num">
                    </el-option>
                </el-select>

                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="Transmitted">确 定</el-button>
                </span>
            </el-dialog>

            <van-popup class="approvePop" v-model="approveShow" closeable close-icon="close" position="bottom"
                :style="{ height: '40%' }">
                <van-field v-model="approveData.approveData" label="审批意见" placeholder="请输入审批意见"></van-field>
                <div class="approveBtns">
                    <van-button type="info" @click="approveSave">保存</van-button>
                </div>
            </van-popup>


            <van-datetime-picker v-show="ApplicationDateshow" v-model="currentExpectDate" type="date" title="申请日期"
                @confirm="confirmApplicationDate" @cancel="ApplicationDateshow = false"></van-datetime-picker>

            <van-datetime-picker v-show="GRDateShow" v-model="currentExpectDate" type="date" title="选择期望交付日期"
                @confirm="confirmGRDate" @cancel="GRDateShow = false"></van-datetime-picker>

            <van-datetime-picker v-show="currentExpectDateShow" v-model="currentExpectDate" type="date" title="选择期望交付日期"
                @confirm="confirmCurrentExpectDate" @cancel="currentExpectDateShow = false"></van-datetime-picker>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {

        var FNScanner = api.require('FNScanner');
        var scanTC80 = api.require('scanTC80');
        var escPrinter = api.require('escPrinter');
        var scanS60A = api.require('ScanS60A');
        var scanDT40 = api.require('scanDT40');
        var FNPhotograph = api.require('FNPhotograph');
        var photoBrowser = api.require('photoBrowser');
        var docReader = api.require('docReader');

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            console.log('ret', JSON.stringify(ret))
            if (ret.value.type == '模具类型') {
                vm.formData.MJLXName = ret.value.row.name
                vm.formData.MJLX = ret.value.row.id
            }
            else if (ret.value.type == '品号') {
                console.log('ret.value.row', JSON.stringify(ret.value.row))
                vm.tableData[vm.currentIndex].ProductCode = ret.value.row.ProductCode1
                vm.tableData[vm.currentIndex].ProductName = ret.value.row.ProductName
                vm.tableData[vm.currentIndex].ProductSpec = ret.value.row.ProductSpec
                vm.tableData[vm.currentIndex].MoludCode = ret.value.row.MoludCode
                vm.tableData[vm.currentIndex].MoludName = ret.value.row.MoludName
                vm.tableData[vm.currentIndex].models = ret.value.row.models
                vm.tableData[vm.currentIndex].CPTH = ret.value.row.TH
                vm.tableData[vm.currentIndex].UnitName = ret.value.row.UnitName
            }
            else if (ret.value.type == '模具分类') {
                console.log('ret.value.row', JSON.stringify(ret.value.row))
                vm.formData.MoludTypeName = ret.value.row.MoludTypeName1
                vm.formData.MoludTypeID = ret.value.row.MoludTypeID
            }
            else if (ret.value.type == '模具编号') {
                console.log('960row', JSON.stringify(ret.value.row))
                vm.tableData[vm.currentIndex].MoludName = ret.value.row.MoludName
                vm.tableData[vm.currentIndex].MoludCode = ret.value.row.MoludCode1
                vm.tableData[vm.currentIndex].ProductName = ret.value.row.ProductName
                vm.tableData[vm.currentIndex].UnitName = ret.value.row.UnitName
                vm.tableData[vm.currentIndex].models = ret.value.row.models
                vm.tableData[vm.currentIndex].GRDate = ret.value.row.GRSJ
                vm.tableData[vm.currentIndex].EquipmentTypeID = ret.value.row.EquipmentTypeID
                vm.tableData[vm.currentIndex].EquipmentTypeName = ret.value.row.EquipmentTypeName
                vm.tableData[vm.currentIndex].FStorageID = ret.value.row.FStorageID
                vm.tableData[vm.currentIndex].FStorageCode = ret.value.row.FStorageCode
            }
            else if (ret.value.type == '吨位') {
                console.log('row', JSON.stringify(ret.value.row))
                vm.tableData[vm.currentIndex].EquipmentTypeID = ret.value.row.EquipmentTypeID
                vm.tableData[vm.currentIndex].EquipmentTypeName = ret.value.row.EquipmentTypeName
            }
            else if (ret.value.type == '库位') {
                console.log('row', JSON.stringify(ret.value.row))
                vm.tableData[vm.currentIndex].FStorageID = ret.value.row.FStorageID
                vm.tableData[vm.currentIndex].FStorageCode = ret.value.row.FStorageCode
            }
            else if (ret.value.type == '申请人') {
                vm.formData.EmplName = ret.value.row.name
                vm.formData.EmplID = ret.value.row.userID
                vm.getClass()
            }
        })

        vm = new Vue({
            el: '#app',
            data: {
                options: [],
                TransmittedUserID: '',
                dialogVisible: false,
                currentExpectDate: new Date(),
                currentExpectDateShow: false,
                ApplicationDateshow: false,
                GRDateShow: false,
                GRDateIndex: 0,
                titleName: api.pageParam.titleName,
                isPDA: api.deviceModel.indexOf('PDA') > -1 ? true : false,
                printConfig: '',
                formData: {
                    id: '',
                    Ck_ReviewID: '',
                    MoldRequisitionID: '',
                    BillDate: '',
                    BillNO: '',
                    TotalPrice: '',
                    ReasonApplication: '',
                    FilePath: [],
                    MoludTypeName: '',
                    MoludTypeID: '',
                    ClassName: '',
                    ClassID: '',
                    EmplName: '',
                    EmplID: '',
                    MJLXName: '',
                    MJLX: '',
                    FRemarks: '',
                    ExpectDate: '',
                    UserName: '',
                    ApplicationDate: ''
                },
                currentActive: '1',
                listLoading: false,
                listFinished: true,
                tableData: [
                    {
                        models: '',
                        CPTH: '',
                        MoludName: '',
                        MoludCode: '',
                        UnitName: '',
                        Price: '',
                        Money: '',
                        Qty: 1,
                        GRDate: '',
                        FQty: 0,
                        ProductCode: '',
                        Productspec: '',
                        ProductName: '',
                        FStorageCode: '',
                        FStorageID: '',
                        EquipmentTypeName: '',
                        EquipmentTypeID: ''
                    }
                ],
                EquipmentTypeIDshow: false,
                EquipmentTypeIDlist: [],
                currentIndex: 0,
                serverIP: APP.serverIP(),
                userData: APP.getUserInfo(),
                finalResult: '',
                approvalList: [],
                status: 0,
                approvalID: '',
                approveShow: false,
                approveData: {
                    content: ''
                },
                approveFalg: false,
                btnShow: false,
                whetherShowBtn: true,
            },
            created: function () {
                var that = this
                that.zhuanjiao()
                // that.openEquipmentTypeID()
                // that.tableData[0].GRDate = new Date().toLocaleString()
                if (api.pageParam.historyData) {
                    console.log('api', JSON.stringify(api.pageParam.historyData))
                    that.whetherShowBtn = false
                    that.formData.MoldRequisitionID = api.pageParam.historyData.MoldRequisitionID
                    that.formData.id = api.pageParam.historyData.MJLXName == '请购' ? 1 : 2
                    that.getInitHistoryData()
                    var obj = {
                        BadReviewID: that.formData.MoldRequisitionID,
                        ReviewType: 2
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('selectBHGPSIDByDGID', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0]) {  //获取评审流程\
                            that.formData.UserName = res.ds[0].Creater
                            that.formData.Ck_ReviewID = res.ds[0].Ck_MJQGBFReviewID
                            that.getApproveData()
                            that.checkIsShowButton()
                        }
                    })
                } else {
                    that.whetherShowBtn = true
                    that.formData.BillNO = '自动生成'
                    that.formData.BillDate = APP.getFormatDateTime(new Date()).split(' ')[0]
                    that.formData.ApplicationDate = APP.getFormatDateTime(new Date()).split(' ')[0]
                    that.formData.ExpectDate = APP.getFormatDateTime(new Date()).split(' ')[0]
                    that.formData.EmplID = APP.getUserInfo().UserID
                    that.formData.EmplName = APP.getUserInfo().UserName
                    that.formData.ReviewStatus = '未审批'
                    that.formData.MJLXName = "请购"
                    that.formData.MJLX = 1
                    that.getClass()
                }
            },
            mounted() {
                var navBar = document.getElementById('van-nav-bar')
                navBar.style.paddingTop = api.safeArea.top + 'px'
            },
            methods: {
                handleClose() {
                    var that = this
                    that.dialogVisible = false
                },
                Transmitted() {
                    var that = this
                    var obj = {
                        TableName: 'Ba_MoldRequisition',
                        APFlowID: 4,
                        ApprovalSortCZ: that.approvalList[that.approvalList.length - 1].level + 1,
                        ReviewType: 2,
                        ApprovalID: that.formData.MoldRequisitionID,
                        UserCode: that.TransmittedUserID
                    }
                    console.log('BhgQjzjpsbgApproveList', JSON.stringify(obj))
                    APP.ajax('BhgQjzjpsbgApprove', obj, function (res) {
                        if (res.ds[0].status == 200) {
                            console.log('BhgQjzjpsbgApprove', JSON.stringify(res))
                            that.dialogVisible = false
                            api.toast({
                                msg: res.ds[0].msg
                            })
                            that.addSP_Message(4)
                        }

                    })
                    // that.dialogVisible = false
                },
                zhuanjiao(val) {
                    var that = this
                    APP.ajax('PC_PCRYXL', {}, function (res) {
                        console.log('PC_PCRYXL', JSON.stringify(res))
                        that.options = res.ds
                    })
                },
                addSP_Message(val) {
                    var that = this
                    var obj1 = {
                        SourceTable: 'Ba_MoldRequisition',
                        ApprovalSortCZ: that.approvalList[that.approvalList.length - 1].level + 1,
                        SourceID: that.formData.MoldRequisitionID,
                        UserCode: that.TransmittedUserID,
                        Status: val,
                        UserID: APP.getUserInfo().UserID,
                    }
                    APP.ajax('SP_Message', obj1, function (res) {
                        if (res.ds[0].status == 200) {
                            console.log('BhgQjzjpsbgApprove', JSON.stringify(res))
                            api.toast({
                                msg: res.ds[0].msg
                            })
                        }
                    })

                },


                chnageGRDateShow(index) {
                    var that = this
                    that.GRDateIndex = index
                    that.GRDateShow = true
                },
                getClass() {
                    var that = this
                    APP.ajax('APP_SelectCJByUserID', { UserID: that.formData.EmplID }, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].status == 500) {
                            api.toast({
                                msg: res.ds[0].msg
                            })
                        } else {
                            that.formData.ClassID = res.ds1[0].ClassID
                            that.formData.ClassName = res.ds1[0].ClassName
                        }
                    })
                },
                confirmApplicationDate(val) {
                    var that = this
                    that.formData.ApplicationDate = APP.getFormatDateTime(val).split(' ')[0]
                    that.ApplicationDateshow = false
                },
                confirmGRDate(val) {
                    var that = this
                    that.tableData[that.GRDateIndex].GRDate = APP.getFormatDateTime(val).split(' ')[0]
                    that.GRDateShow = false
                },
                confirmCurrentExpectDate(val) {
                    var that = this
                    that.formData.ExpectDate = APP.getFormatDateTime(val).split(' ')[0]
                    that.currentExpectDateShow = false
                },
                onClickLeft() {
                    api.closeWin();
                },
                getInitHistoryData() {
                    var that = this
                    APP.ajax('APP_MJQGBFMX', { MoldRequisitionID: that.formData.MoldRequisitionID, MJLX: that.formData.id }, function (res) {
                        console.log('1083res', JSON.stringify(res))
                        that.formData.MoludCode = res.ds[0].MoludCode
                        that.formData.BillDate = res.ds[0].BillDate
                        that.formData.BillNO = res.ds[0].BillNO
                        that.formData.EmplID = res.ds[0].EmplID
                        that.formData.EmplName = res.ds[0].UserName
                        that.formData.ClassID = res.ds[0].ClassID
                        that.formData.ClassName = res.ds[0].ClassName
                        that.formData.MoludTypeName = res.ds[0].MoludTypeName
                        that.formData.MoludTypeID = res.ds[0].MoludTypeID
                        that.formData.ReasonApplication = res.ds[0].ReasonApplication
                        // that.formData.FilePath = res.ds[0].FilePath.join(',')
                        var arr = res.ds[0].FilePath.split(',')
                        arr.map((item) => {
                            that.formData.FilePath.push({ url: item })
                        })


                        that.formData.TotalPrice = res.ds[0].TotalPrice
                        that.formData.FRemarks = res.ds[0].FRemarks
                        that.formData.MJLX = res.ds[0].MJLX
                        that.formData.MJLXName = res.ds[0].MJLXName
                        that.formData.ReviewStatus = res.ds[0].ReviewStatus
                        that.formData.ExpectDate = res.ds[0].ExpectDate
                        that.formData.ApplicationDate = res.ds[0].ApplicationDate
                        that.tableData = res.ds1
                        console.log('res.ds1', JSON.stringify(res.ds1))
                    })
                },

                checkIsShowButton: function () {
                    var that = this;
                    var obj = {
                        P_TableName: 'Ba_MoldRequisition',
                        P_PKValue: that.formData.MoldRequisitionID
                    }
                    console.log('Btnobj', JSON.stringify(obj))
                    APP.ajax('WhetherItCanBeApproved', obj, function (res) {
                        console.log('Btnres', JSON.stringify(res))
                        that.btnShow = res.ds[0].ISSP;
                    })
                },

                getApprovalTagImg: function (row) {
                    var that = this;
                    if (row.node.length == 1) {
                        if (row.node[0].Approve == 0) {
                            return '../../image/doing.png';
                        } else if (row.node[0].Approve == 1) {
                            return '../../image/success.png';
                        } else if (row.node[0].Approve == 2) {
                            return '../../image/fail.png';
                        }
                    } else {

                        var imgstr = '';
                        var z = 0;
                        for (var i in row.node) {
                            if (row.node[i].Approve == 1) {
                                z++;
                            }
                            if (row.node[i].Approve == 2) {
                                imgstr = '../../image/fail.png';
                                break;
                            }
                        }
                        if (imgstr) {
                            return imgstr;
                        } else {
                            if (z == 0) {
                                imgstr = '../../image/doing.png'
                            } else {
                                if (row.node.length == z) {
                                    imgstr = '../../image/success.png'
                                } else {
                                    imgstr = '../../image/doing.png';
                                }
                            }

                        }
                        return imgstr;
                    }
                },

                filterPersonList: function (str, value) {
                    var that = this;
                    var row = null;
                    for (var i in that.personList) {
                        if (that.personList[i][str] == value) {
                            row = that.personList[i];
                            break;
                        }
                    }
                    return row;
                },

                getApproveData() {
                    var that = this
                    var obj = {
                        Ck_ReviewID: that.formData.Ck_ReviewID,
                        ReviewType: 2
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('getBHGPSCkReviewByID', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        that.status = res.ds[0].Status
                        that.approvalID = res.ds[0].APFlowID
                        var obj2 = {
                            P_PKValue: that.formData.MoldRequisitionID,
                            P_TableName: 'Ba_MoldRequisition'
                        }
                        console.log('obj2', JSON.stringify(obj2))
                        APP.ajax('Select_FlowLog1', obj2, function (res) {
                            console.log('res', JSON.stringify(res))
                            // console.log('APP.getUserInfo().UserName', JSON.stringify(APP.getUserInfo().UserName))
                            // console.log('res.ds[0].Creater', JSON.stringify(res.ds[0].Creater))
                            if (APP.getUserInfo().UserName == res.ds[0].Creater) {
                                res.ds.map((item) => {
                                    if (item.Approve == 2) {
                                        that.approveFalg = true
                                    }
                                })
                                // console.log('approveFalg', JSON.stringify(that.approveFalg))
                            }


                            var data = [];
                            allCurrentApprovalIDs = [];
                            var allCurrentApprovalIDs2 = [];
                            for (var i in res.ds) {

                                res.ds[i].CurrentApprovalIDs = res.ds[i].CurrentApprovalIDs ? res.ds[i].CurrentApprovalIDs.replace(/^,+/, "").replace(/,+$/, "").split(',') : '';

                                allCurrentApprovalIDs = allCurrentApprovalIDs.concat(res.ds[i].CurrentApprovalIDs);
                                if (res.ds[i].FlowType != 1) {
                                    allCurrentApprovalIDs2 = allCurrentApprovalIDs2.concat(res.ds[i].CurrentApprovalIDs);
                                }
                                for (var c in res.ds[i].CurrentApprovalIDs) {
                                    var row = that.filterPersonList('UserID', res.ds[i].CurrentApprovalIDs[c])
                                    if (row) {
                                        res.ds[i].CurrentApprovalIDs[c] = row.UserName;
                                    }
                                }

                                if (data.indexOf(res.ds[i].AuditID) == -1) {
                                    data.push(res.ds[i].AuditID);
                                }
                            }

                            var approvalList = [];
                            for (var n in data) {
                                var approvalNodeList = [];
                                var level = 0;
                                var finLevel = 0;
                                for (var i in res.ds) {
                                    if (data[n] == res.ds[i].AuditID) {

                                        if (res.ds[i].Approve == 0 && !level) {
                                            level = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 1 && i == res.ds.length - 1) {
                                            level = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 2 && !finLevel) {
                                            finLevel = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 2 && n == data.length - 1) {
                                            that.finalResult = 2;
                                        }

                                        var x = 0;
                                        for (var j in approvalNodeList) {
                                            if (approvalNodeList[j].index == res.ds[i].ApprovalSort) {
                                                x = 1;
                                                approvalNodeList[j].node.push(res.ds[i]);
                                            }
                                        }
                                        if (!x) {
                                            approvalNodeList.push({
                                                index: res.ds[i].ApprovalSort,
                                                type: res.ds[i].FlowType,
                                                department: res.ds[i].ApprovalName,
                                                node: [res.ds[i]]
                                            })
                                        }
                                    }
                                }
                                approvalList.push({
                                    level: finLevel ? (finLevel - 1) : (level - 1),
                                    approvalNodeList: approvalNodeList
                                })
                            }

                            var p1 = 0;
                            var y = 0;
                            if (that.finalResult == 1) {
                                for (var i in res.ds) {
                                    if (res.ds[i].Approver && res.ds[i].FlowType != 1) {
                                        p1++;
                                        if (res.ds[i].Approver == that.userData.UserName) {
                                            y = 1;
                                        }
                                    }
                                }
                                // console.log('Ck_ReviewID', JSON.stringify(that.formData.Ck_ReviewID))
                            }
                            that.approvalList = approvalList;
                            console.log('approvalList', JSON.stringify(that.approvalList))
                        })
                    })
                },

                addNewSubTable() {
                    var that = this
                    var table = {
                        models: '',
                        CPTH: '',
                        MoludName: '',
                        MoludCode: '',
                        UnitName: '',
                        Price: '',
                        Money: '',
                        Qty: 1,
                        GRDate: '',
                        FQty: 0,
                        ProductCode: '',
                        Productspec: '',
                        ProductName: '',
                        FStorageCode: '',
                        FStorageID: '',
                        EquipmentTypeName: '',

                    }
                    that.tableData.push(table)
                },

                deleteTableData(index) {
                    var that = this
                    that.tableData.splice(index, 1)
                },

                openBaseScreen: function (str, index) {
                    console.log('str', JSON.stringify(str))
                    var that = this;
                    that.currentIndex = index
                    var obj;
                    if (str == '模具类型') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'APPMJLXXL',
                            param: {

                            }
                        }
                    }
                    else if (str == '模具分类') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: 'MoludTypeName',
                            serverSearch: false,
                            searchBy: ['MoludTypeName'],
                            isPaging: true,
                            type: str,
                            cmd: 'mjfl_xl',
                            param: {
                                pageIndex: 1,
                                pageSize: 20
                            }
                        }
                    }
                    else if (str == '吨位') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: true,
                            searchBy: ['EquipmentTypeID'],
                            isPaging: false,
                            type: str,
                            cmd: 'MJBFDW_XL',
                            param: {
                                pageIndex: 1,
                                pageSize: 20
                            }
                        }
                    }
                    else if (str == '库位') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: true,
                            searchBy: ['FStorageCode'],
                            isPaging: false,
                            type: str,
                            cmd: 'MJBFKW_XL',
                            param: {
                                pageIndex: 1,
                                pageSize: 20
                            }
                        }
                    }

                    else if (str == '品号') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: 'ProductCode',
                            serverSearch: true,
                            searchBy: ['ProductCode'],
                            isPaging: true,
                            type: str,
                            cmd: 'MJCP_XL',
                            param: {
                                pageIndex: 1,
                                pageSize: 20
                            }
                        }
                    }
                    else if (str == '模具编号') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: 'MoludCode',
                            serverSearch: true,
                            searchBy: ['MoludCode'],
                            isPaging: true,
                            type: str,
                            cmd: 'MJBH_XL',
                            param: {
                                pageIndex: 1,
                                pageSize: 20
                            }
                        }
                    } else if (str == '申请人') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'FQR_XL',
                            param: {
                            }
                        }
                    }
                    api.openWin({
                        name: 'baseScreen',
                        url: '../tool/baseScreen.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: obj
                    })
                },

                previewImg() {
                    var that = this
                    document.activeElement.blur();
                    var imgFlag = 0
                    var imageArr = []
                    that.formData.FilePath.map((item) => {
                        imageArr.push(that.serverIP + item.url)
                    })
                    photoBrowser.open({
                        images: imageArr,
                        bgColor: '#000'
                    }, function (ret, err) {
                        if (ret) {
                            // alert(JSON.stringify(ret));
                            if (ret.eventType == 'show') {
                                imgFlag = 1
                            }
                            if (ret.eventType == 'click') {
                                imgFlag = 0
                                photoBrowser.close();
                            }
                        } else {
                            layer.open({
                                content: '图片打开失败，请重试！',
                                skin: 'msg',
                                time: 2
                            });
                        }
                    });
                },


                // previewImg() {
                //     var that = this
                //     document.activeElement.blur();
                //     var imgFlag = 0
                //     photoBrowser.open({
                //         images: [
                //             that.serverIP + that.formData.FilePath
                //         ],
                //         bgColor: '#000'
                //     }, function (ret, err) {
                //         if (ret) {
                //             // alert(JSON.stringify(ret));
                //             if (ret.eventType == 'show') {
                //                 imgFlag = 1
                //             }
                //             if (ret.eventType == 'click') {
                //                 imgFlag = 0
                //                 photoBrowser.close();
                //             }
                //         } else {
                //             layer.open({
                //                 content: '图片打开失败，请重试！',
                //                 skin: 'msg',
                //                 time: 2
                //             });
                //         }
                //     });
                // },

                deleteImg(index) {
                    var that = this
                    that.formData.FilePath.splice(index, 1)
                },
                uploadNewFile(index) {
                    var that = this
                    var url = APP.serverIP() + '/Frame/uploadImgFile?dirName=首件检';
                    $.ajaxFileUpload({
                        type: 'POST',
                        url: url,
                        secureuri: false,
                        fileElementId: 'newFile' + index,
                        dataType: 'json',
                        success: function (datas, status) {
                            console.log('datas', JSON.stringify(datas))
                            if (datas.status == 200) {
                                if (index == 1) {
                                    that.formData.FilePath.push({ url: datas.data.origin })
                                }
                            } else {
                                // alert(JSON.stringify(datas))
                                vm.$toast('上传失败');
                            }
                        },

                    });

                },


                addImg() {
                    var that = this
                    document.activeElement.blur();
                    FNPhotograph.open({
                        path: 'fs://savePath',
                        album: true,
                        quality: 'medium'
                    }, function (ret) {
                        // alert(JSON.stringify(ret));
                        if (ret.eventType == 'takePhoto') {
                            that.$toast('照片上传中...')
                            APP.uploadFile('首件检', ret.imagePath, function (path) {
                                console.log('path', JSON.stringify(path))
                                that.formData.FilePath.push({ url: path })
                            })
                            FNPhotograph.close(
                                function (ret) {
                                    if (ret) {
                                        // alert(JSON.stringify(ret));
                                    }
                                });
                        } else if (ret.eventType == 'cameraError') {
                            that.$toast('相机打开失败，请重试！')
                        }
                    });
                },



                handlerTotalPrice(val, index) {
                    var that = this

                    if (that.formData.MJLXName == '请购') {
                        that.formData.TotalPrice = that.tableData.reduce((acc, obj) => acc + (Number(obj.Price) * Number(obj.Qty)), 0)

                    } else {
                        that.formData.TotalPrice = that.tableData.reduce((acc, obj) => acc + (Number(obj.Price)), 0)
                    }
                    if (that.tableData[index].Price == '' || that.tableData[index].Qty == '') {
                        that.tableData[index].Money = ''
                        return
                    } else {
                        that.tableData[index].Money = Number(that.tableData[index].Price) * Number(that.tableData[index].Qty)
                    }

                    // console.log('TotalPrice', JSON.stringify(that.formData.TotalPrice))
                },
                saveRow() {
                    that = this
                    var obj
                    if (that.formData.MJLXName == '请购') {
                        if (that.formData.ReasonApplication == '') {
                            api.confirm({
                                msg: '请输入申请事由',
                                buttons: ['取消', '确定']
                            }, function (ret) {
                            })
                            return
                        }
                        else {
                            obj = {
                                Money: that.tableData.map(item => item.Money).join('@'),
                                CPTH: that.tableData.map(item => item.CPTH).join('@'),
                                ProductSpec: that.tableData.map(item => item.UnitName).join('@'),
                                UnitName: that.tableData.map(item => item.UnitName).join('@'),
                                Price1: that.tableData.map(item => item.Price).join('@'),
                                Qty1: that.tableData.map(item => item.Qty).join('@'),
                                EquipmentTypeID1: that.tableData.map(item => item.EquipmentTypeID).join('@'),
                                ProductName: that.tableData.map(item => item.ProductName).join('@'),
                                ProductCode: that.tableData.map(item => item.ProductCode).join('@'),
                                FRemarks: that.formData.FRemarks,
                                TotalPrice: that.formData.TotalPrice,
                                ReasonApplication: that.formData.ReasonApplication,
                                FilePath: that.formData.FilePath.map(item => item.url).join(','),
                                ClassID: that.formData.ClassID,
                                EmplID: that.formData.EmplID,
                                MJLX: that.formData.MJLX,
                            }
                        }
                    }
                    else {
                        if (that.formData.ReasonApplication == '') {
                            api.confirm({
                                msg: '请输入申请事由',
                                buttons: ['取消', '确定']
                            }, function (ret) {
                            })
                            return
                        }
                        else {
                            obj = {
                                models: that.tableData.map(item => item.models).join('@'),
                                Price: that.tableData.map(item => item.Price).join('@'),
                                MoludCode: that.tableData.map(item => item.MoludCode).join('@'),
                                Qty: that.tableData.map(item => item.Qty).join('@'),
                                MoludName: that.tableData.map(item => item.MoludName).join('@'),
                                MoludTypeID: that.formData.MoludTypeID,
                                GRDate: that.tableData.map(item => item.GRDate).join('@'),
                                FRemarks: that.formData.FRemarks,
                                TotalPrice: that.formData.TotalPrice,
                                ReasonApplication: that.formData.ReasonApplication,
                                FilePath: that.formData.FilePath.map(item => item.url).join(','),
                                ClassID: that.formData.ClassID,
                                EmplID: that.formData.EmplID,
                                MJLX: that.formData.MJLX,
                                FQty: that.tableData.map(item => item.FQty).join('@'),
                                EquipmentTypeID: that.tableData.map(item => item.EquipmentTypeID).join('@'),
                                FStorageID: that.tableData.map(item => item.FStorageID).join('@'),
                            }

                        }

                    }

                    // var obj = {
                    //     models: that.tableData.map(item => item.models).join('~'),
                    //     CPTH: that.tableData.map(item => item.CPTH).join('~'),
                    //     MoludName: that.tableData.map(item => item.MoludName).join('~'),
                    //     MoludCode: that.tableData.map(item => item.MoludCode).join('~'),
                    //     UnitName: that.tableData.map(item => item.UnitName).join('~'),
                    //     Price: that.tableData.map(item => item.Price).join('~'),
                    //     Qty: that.tableData.map(item => item.Qty).join('~'),
                    //     FRemarks: that.formData.FRemarks,
                    //     TotalPrice: that.formData.TotalPrice,
                    //     ReasonApplication: that.formData.ReasonApplication,
                    //     FilePath: that.formData.FilePath.map(item => item.url).join(','),
                    //     MoludTypeID: that.formData.MoludTypeID,
                    //     ClassID: that.formData.ClassID,
                    //     EmplID: that.formData.EmplID,
                    //     MJLX: that.formData.MJLX,
                    // }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax("APP_MJQGBF_ADD", obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].status == 200) {
                            that.formData.BillNO = res.ds[0].BillNO3
                            that.formData.MoldRequisitionID = res.ds[0].MoldRequisitionID
                            var obj1 = {
                                UserID: that.formData.EmplID,
                                NgCause: '',
                                IsReworkDepart: -1,
                                ClassID: that.formData.ClassID,
                                FRemarks: that.formData.FRemarks,
                                ReviewType: 2,
                                P_Timeout: 0,
                                BadReviewID: that.formData.MoldRequisitionID
                            }
                            console.log('obj1', JSON.stringify(obj1))
                            APP.ajax('addBHGPSReviewApprove', obj1, function (res) {
                                console.log('res', JSON.stringify(res))
                                that.formData.Ck_ReviewID = res.ds[0].Ck_ReviewID
                                var obj2 = {
                                    TableName: 'Ck_MJQGBFReview',
                                    approveType: 0,
                                    Ck_ReviewID: that.formData.Ck_ReviewID,
                                    ApprovalID: that.formData.MoldRequisitionID,
                                    APFlowID: 4,
                                    ReviewType: 2
                                }
                                console.log('obj2', JSON.stringify(obj2))
                                APP.ajax('BhgpsbgApprove', obj2, function (res) {
                                    console.log('res', JSON.stringify(res))
                                    if (res.ds[0].status == 0) {
                                        vm.$toast('提交审批成功！');

                                        api.sendEvent({
                                            name: 'refresh'
                                        })
                                        setTimeout(() => {
                                            api.closeWin()
                                        }, 1500)
                                    } else {
                                        vm.$toast(res.ds[0].msg);
                                    }
                                })
                            })

                        } else {
                            vm.$toast('提交失败，请重试！');
                        }
                    })

                },

                approveSave() {
                    var that = this
                    obj = {
                        Approve: that.approveFlag,
                        TableName: 'Ba_MoldRequisition',
                        KeyID: that.formData.MoldRequisitionID,
                        ApprovalContent: that.approveData.approveData,
                        ApprovalID: 4,
                        ApprovalSort: that.approvalList[that.approvalList.length - 1].level + 1,
                        Imgs: '',
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('Ck_ApprovalForm', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].STATUS == 0) {
                            var obj1 = {
                                BadReviewID: that.formData.MoldRequisitionID,
                                UserID: APP.getUserInfo().UserID,
                                status: that.approveFlag == 1 ? 0 : 1,
                                ReviewType: 2,
                                SourceTable: 'Ba_MoldRequisition'
                            }
                            console.log('obj1', JSON.stringify(obj1))
                            APP.ajax('selectQJPSSPZTByUserID', obj1, function (res) {
                                console.log('res', JSON.stringify(res))
                                if (res.ds[0].status == 200) {
                                    vm.$toast(res.ds[0].msg)
                                    that.addSP_Message(that.approveFlag)

                                    api.sendEvent({
                                        name: 'refresh'
                                    })
                                    setTimeout(() => {
                                        api.closeWin()
                                    }, 1500)
                                } else {
                                    vm.$toast(res.ds[0].msg)
                                }
                            })
                        } else {
                            vm.$toast(res.ds[0].msg)
                        }
                    })
                },

                submit(flag) {
                    var that = this
                    that.approveFlag = flag
                    if (flag != 0) {  //同意/拒绝
                        that.approveShow = true
                    } else {  //重新发起审批
                        console.log('Ck_ReviewID11111111', JSON.stringify(that.formData.Ck_ReviewID))
                        var obj
                        if (that.formData.MJLXName == '请购') {
                            obj = {
                                EquipmentTypeID1: that.tableData.map(item => item.EquipmentTypeID).join('@'),
                                ProductSpec: that.tableData.map(item => item.UnitName).join('@'),
                                Money: that.tableData.map(item => item.Money).join('@'),
                                Price1: that.tableData.map(item => item.Price).join('@'),
                                Qty1: that.tableData.map(item => item.Qty).join('@'),
                                EquipmentTypeID: that.tableData.map(item => item.EquipmentTypeID).join('@'),
                                FStorageID: that.tableData.map(item => item.FStorageID).join('@'),
                                ProductName: that.tableData.map(item => item.ProductName).join('@'),
                                ProductCode: that.tableData.map(item => item.ProductCode).join('@'),
                                models: that.tableData.map(item => item.models).join('@'),
                                MoludName: that.tableData.map(item => item.MoludName).join('@'),
                                MoldRequisitionDeID: that.tableData.map(item => item.MoldRequisitionDeID).join('@'),
                                MoludCode: that.tableData.map(item => item.MoludCode).join('@'),
                                CPTH: that.tableData.map(item => item.CPTH).join('@'),
                                MoldRequisitionID: that.formData.MoldRequisitionID,
                                EmplID: that.formData.EmplID,
                                UnitName: that.tableData.map(item => item.UnitName).join('@'),
                                Price: that.tableData.map(item => item.Price).join('@'),
                                Qty: that.tableData.map(item => item.Qty).join('@'),
                                FilePath: that.formData.FilePath.map(item => item.url).join(','),
                                FRemarks: that.formData.FRemarks,
                                ReasonApplication: that.formData.ReasonApplication,
                                MJLX: that.formData.MJLX,
                                // ClassID: that.formData.ClassID,
                                MoludTypeID: that.formData.MoludTypeID ? '' : 0,
                                GRDate: that.tableData.map(item => item.GRDate).join('@'),
                                FQty: that.tableData.map(item => item.FQty).join('@'),
                            }
                        } else {
                            obj = {
                                EquipmentTypeID1: that.tableData.map(item => item.EquipmentTypeID).join('@'),
                                ProductSpec: that.tableData.map(item => item.UnitName).join('@'),
                                Money: that.tableData.map(item => item.Money).join('@'),
                                Price1: that.tableData.map(item => item.Price).join('@'),
                                Qty1: that.tableData.map(item => item.Qty).join('@'),
                                EquipmentTypeID: that.tableData.map(item => item.EquipmentTypeID).join('@'),
                                FStorageID: that.tableData.map(item => item.FStorageID).join('@'),
                                ProductName: that.tableData.map(item => item.ProductName).join('@'),
                                ProductCode: that.tableData.map(item => item.ProductCode).join('@'),
                                models: that.tableData.map(item => item.models).join('@'),
                                MoludName: that.tableData.map(item => item.MoludName).join('@'),
                                MoldRequisitionDeID: that.tableData.map(item => item.MoldRequisitionDeID).join('@'),
                                MoludCode: that.tableData.map(item => item.MoludCode).join('@'),
                                CPTH: that.tableData.map(item => item.CPTH).join('@'),
                                MoldRequisitionID: that.formData.MoldRequisitionID,
                                EmplID: that.formData.EmplID,
                                UnitName: that.tableData.map(item => item.UnitName).join('@'),
                                Price: that.tableData.map(item => item.Price).join('@'),
                                Qty: that.tableData.map(item => item.Qty).join('@'),
                                FilePath: that.formData.FilePath.map(item => item.url).join(','),
                                FRemarks: that.formData.FRemarks,
                                ReasonApplication: that.formData.ReasonApplication,
                                MJLX: that.formData.MJLX,
                                // ClassID: that.formData.ClassID,
                                MoludTypeID: that.formData.MoludTypeID,
                                GRDate: that.tableData.map(item => item.GRDate).join('@'),
                                FQty: that.tableData.map(item => item.FQty).join('@'),
                            }
                        }
                        console.log('obj', JSON.stringify(obj))
                        APP.ajax('APP_MJQGBF_UPDATE', obj, function (res) {
                            if (res.ds[0].status == 200) {
                                var obj1 = {
                                    BadReviewID: that.formData.MoldRequisitionID,
                                    NgCause: '',
                                    UserID: APP.getUserInfo().UserID,
                                    IsReworkDepart: 1,
                                    ClassID: that.formData.ClassID,
                                    Ck_BHGPSReviewID: that.formData.Ck_ReviewID,
                                    P_Timeout: 0,
                                    ReviewType: 2
                                }
                                console.log('obj', JSON.stringify(obj))
                                APP.ajax('updateBHGPSApproveReview', obj1, function (res) {
                                    console.log('res', JSON.stringify(res))
                                    if (res.ds && res.ds[0].status == 500) {
                                        vm.$toast(res.ds[0].msg)
                                    } else {
                                        vm.$toast('重新发起审批成功！')
                                        that.addSP_Message(that.approveFlag)

                                        api.sendEvent({
                                            name: 'refresh'
                                        })
                                        setTimeout(() => {
                                            api.closeWin()
                                        }, 1500)
                                    }
                                })
                                // vm.$toast('修改成功！');

                                // api.sendEvent({
                                //     name: 'refresh'
                                // })
                            } else {
                                vm.$toast('修改失败，请重试！');
                            }
                        })
                    }
                },

                //摄像头扫描事件
                openScan() {
                    var resultList = api.hasPermission({
                        list: ['camera']
                    });
                    if (resultList[0].granted) {
                        // 已授权，可以继续下一步操作
                        FNScanner.open({
                            autorotation: true
                        }, function (ret, err) {
                            if (ret) {
                                if (ret.content) {
                                    api.sendEvent({
                                        name: 'scanHandler',
                                        extra: {
                                            scanData: ret.content
                                        }
                                    })
                                }
                            } else {
                                vm.$toast('扫描失败');
                            }
                        });
                    } else {
                        api.confirm({
                            msg: '应用需要您的授权才能访问相机',
                            buttons: ['取消', '去设置']
                        }, function (ret) {
                            if (ret.buttonIndex == 2) {
                                api.requestPermission({
                                    list: ['camera'],
                                }, function (res) {
                                    if (res.list[0].granted) {
                                        // 已授权，可以继续下一步操作
                                        FNScanner.open({
                                            autorotation: true
                                        }, function (ret, err) {
                                            if (ret) {
                                                if (ret.content) {
                                                    api.sendEvent({
                                                        name: 'scanHandler',
                                                        extra: {
                                                            scanData: ret.content
                                                        }
                                                    })
                                                }
                                            } else {
                                                vm.$toast('扫描失败');
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }


                    // var hwScanner = api.require('hwScanner');
                    // hwScanner.defaultScanner({
                    //     formatType: 'ALL'
                    // }, function (ret) {
                    //     if (ret.status) {
                    //         api.sendEvent({
                    //             name: 'scanHandler',
                    //             extra: {
                    //                 scanData: ret.result
                    //             }
                    //         })
                    //     }
                    //     else {
                    //         vm.$toast('扫描失败');
                    //     }
                    // });
                },

                //打开打印
                openPrint() {
                    if (vm.printConfig) {
                        var script = vm.printConfig.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                    }
                },
            }
        })
    };
</script>

</html>